//
//  GoodsOrderInfoCell.m
//  EasyToTesco2.0
//
//  Created by 杨森 on 2016/10/29.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "GoodsOrderInfoCell.h"

@implementation GoodsOrderInfoCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self buildCellView];
    }
    return self;
}

-(void)buildCellView
{
    float margin = 10;
    
    
    _goodsImg = [[UIImageView alloc] init];
    [self.contentView addSubview:_goodsImg];
    
    
    _goodsPrice = [[UILabel alloc] init];
    _goodsPrice.font = FONT(12);
    _goodsPrice.textAlignment = NSTextAlignmentRight;
    _goodsPrice.textColor = [UIColor blackColor];
    [self.contentView addSubview:_goodsPrice];
    
    _goodsNum = [[UILabel alloc] init];
    _goodsNum.font = FONT(12);
    _goodsNum.textColor = [UIColor grayColor];
    _goodsNum.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_goodsNum];
   
    _goodsName = [[UILabel alloc] init];
    _goodsName.font = FONT(12);
    _goodsName.textColor = [UIColor blackColor];
    _goodsName.numberOfLines = 2;
    [self.contentView addSubview:_goodsName];
    
    _guige = [[UILabel alloc] init];
    _guige.font = FONT(12);
    _guige.numberOfLines = 2;
    _guige.textColor = [UIColor grayColor];
    [self.contentView addSubview:_guige];
    
    [_goodsImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(margin);
        make.top.equalTo(self.contentView.mas_top).offset(margin);
        make.width.height.mas_equalTo(60);
    }];
    
    
    [_goodsPrice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).offset(-margin);
        make.top.equalTo(self.contentView.mas_top).offset(margin);
    }];
    
    
    
    [_goodsNum mas_makeConstraints:^(MASConstraintMaker *make) {
        
        if (_guige.text.length) {
            make.bottom.equalTo(_guige.mas_bottom);
        }else{
            make.top.equalTo(_goodsPrice.mas_bottom).offset(10);
        }
        make.right.equalTo(_goodsPrice.mas_right);
    }];
    
    [_goodsName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_goodsImg.mas_right).offset(margin);
        make.top.equalTo(_goodsPrice.mas_top);
        make.right.equalTo(_goodsPrice.mas_left).offset(15);
    }];
    
    [_guige mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_goodsImg.mas_right).offset(margin);
        make.top.equalTo(_goodsName.mas_bottom).offset(5);
        make.width.mas_equalTo(_goodsName.mas_width);
    }];
}

@end
